<?php
/**
 * @category	Modules
 * @package		JomSocial
 * @copyright (C) 2008 by Slashes & Dots Sdn Bhd - All rights reserved!
 * @license		GNU/GPL, see LICENSE.php
 */
defined('_JEXEC') or die('Restricted access');

class modVideoCommentsHelper
{
	function getList(&$params)
	{
		$db		=& JFactory::getDBO();
		
		$limit	= $params->get( 'count' , 5 );
		
		$permissions	= '';
		if ($params->get('privacy'))
		{
			$my		=& JFactory::getUser();
			$permissions	= ($my->id==0) ? 0 : 20;
			$permissions	= ' AND b.' . $db->nameQuote('permissions').' <= ' . $db->Quote($permissions) ." ";
		} 

		$query	= 'SELECT * FROM ' . $db->nameQuote('#__community_wall').' AS a '
				. ' INNER JOIN ' . $db->nameQuote('#__community_videos').' AS b '
				. ' ON a.' . $db->nameQuote('contentid').'=b.' . $db->nameQuote('id')
				. ' WHERE a.' . $db->nameQuote('type').' =' . $db->Quote('videos')
				. 'AND b.' . $db->nameQuote('status').' =' . $db->Quote('ready')
				. $permissions
				. 'ORDER BY a.' . $db->nameQuote('date').' DESC '
				. 'LIMIT ' . $limit;
				
		$db->setQuery( $query );
		
		$comments	= $db->loadObjectList();

		return $comments; 
	}
}
